{include file="public/head"}

<body>
	<div class="x-body">
		<form class="lotus-nav">
			<input type="hidden" name="id" id="id" value="{$action_id}" />
			<button type="button" class="layui-btn  layui-btn-sm" onclick="x_admin_show('添加券','addCoupon.html?action_id={$action_id}',900,700)">
               添加
            </button>
			
			<div class="layui-input-inline">
				<input id="" name="keyword" class="layui-input lotus-input" placeholder="请输入关键词搜索" value="{$Think.get.keyword}">
			</div>
			<button class="layui-btn layui-btn-sm"><i class="layui-icon layui-icon-search"></i></button>
			<!--<button type="button" class="layui-btn layui-btn-sm" onclick="location='/admin/Admin/index'">重置</button>-->
			<span class="x-right">共有数据:<i class="i_count">{$list->total()}</i>条<!-- <button onclick="javascript:location.reload()" class="layui-btn-default "><i class="layui-icon layui-icon-refresh"></i></button>--></span>
		</form>
		<table class="layui-table">
			<thead>
				<tr>
					<th>ID</th>
					<th>券名称</th>
					<th>促销单号</th>
					<th>总库存</th>
					<th>剩余库存</th>
					<th>所需积分</th>
					<th>创建时间</th>
					<th>状态</th>
					<th>操作</th>
			</thead>
			<tbody>
				{volist name="list" id="vo"}
				<tr>
					<td>{$vo.id}</td>
					<td>{$vo.coupon_name}</td>
					<td>{$vo.promotion_num}</td>
					<td>{$vo.total_stock}</td>
					<td>{$vo.real_stock}</td>
					<td>{$vo.point}</td>
					<td>{$vo.createtime}</td>
					<td>
						{eq name="$vo.status" value="1"}正常{else/}禁用{/eq}
					</td>
					<td>
						<button class="layui-btn layui-btn-xs" onclick="x_admin_show('编辑券','editCoupon.html?id={$vo.id}',900,600)">编辑</button>
						<!--<button class="layui-btn layui-btn-xs" onclick="x_admin_show('编辑用户','/admin/banner/index.html?id={$vo.id}',900,600)">编辑</button>-->
						<!--<button onclick="delUser(this,'{$vo.id}')" class="layui-btn layui-btn-xs layui-btn-danger">删除</button>-->
					</td>
				</tr>
				{/volist}
			</tbody>
		</table>
		<div class="page">
			<div>
				{$list|raw}
			</div>
		</div>
	</div>
</body>
{include file="public/foot"}
<script>
	function delUser(obj, id) {
		var count = $(".i_count")[0].innerText;
		layer.confirm('确认要删除吗？', function(index) {
			//捉到所有被选中的，发异步进行删除
			$.post("{:url('admin/action/deleteAction')}", {
				id: id
			}, function(data, textStatus, xhr) {
				/*optional stuff to do after success */
				console.log(data);
				if(data.code == 1) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function() {
						$(obj).parents('tr').remove();
						$(".i_count").html(count - 1);
					});
				} else {
					layer.msg(data.msg, {
						icon: 2,
						time: 1000
					});
				}

			});
		});
	}
</script>